// 因为如果直接写的话会很麻烦：localStorage.setItem('userinfo', JSON.stringify(userinfo))，
// 就很长，所以封装成一个个的函数，按需导入

// 在utils文件下创建stotage.js
const USER_INFO_KEY = 'userinfo'
const SEARCH_LIST_KEY = 'searchlist'

export const getinfo = () => {
  return localStorage.getItem(USER_INFO_KEY)
}
export const setinfo = (userinfo) => {
  localStorage.setItem(USER_INFO_KEY, JSON.stringify(userinfo))
}
export const removeinfo = () => {
  localStorage.removeItem(USER_INFO_KEY)
}

export const setSearchList = (list) => {
  localStorage.setItem(SEARCH_LIST_KEY, JSON.stringify(list))
}
export const getSearchList = () => {
  return localStorage.getItem(SEARCH_LIST_KEY)
}
export const removeSearchList = () => {
  localStorage.removeItem(SEARCH_LIST_KEY)
}
